/*-------------------<-- Start of Description-->---------------------\ | Open a MS Word document: | | if the path user provided is correct, then open it | | otherwise open an empty one | |---------------------<-- End of Description-->----------------------| |--------------------------------------------------------------------| |------------<-- Start of Files or Arguments Needed-->---------------| | Argument: the path and the name of the word document to be opened; | |-------------<-- End of Files or Arguments Needed-->----------------| |--------------------------------------------------------------------| |------------------<-- Start of Files Created-->---------------------| | Example: %wordopen(Y:\CLINICAL\TACHY\BIOSTAT\Duo\Bonalist.doc); | | Usage: %wordopen(filepath); | \-------------------<-- End of Files Created-->---------------------*/ %macro wordopen/parmbuff; /*--------------------------------------------\ | Copy Right: Duo Zhou; | | Created: 3-27-2001 8:01pm; | | Modified: 1-15-2002 11:06pm; | | Purpose: Open a word document; | \--------------------------------------------*/ %global wordfileref; %local filepath; options noxwait noxsync; x 'Exit'; %let num=1; %let wordfileref=%qscan(&syspbuff,&num,%str(()""'')); %if (%quote(&wordfileref) ne) and (%quote(%upcase(&wordfileref)) ne %quote(NEW)) %then %do; %if (%sysfunc(fileexist(&wordfileref))) %then %do; %put --> Note: Wait! The system is opening Word Document:; %put --> "&wordfileref". ; FILENAME wordsys dde "winword|&wordfileref" command lrecl=1048576; data _null_; length fid rc 8; fid=fopen("wordsys", "s"); if (fid le 0) then do; rc=system("'&wordfileref'"); do until(fid); fid=fopen("wordsys", "s"); end; end; rc=fclose(fid); run; %end; %else %do; %put ==> Alert! Can%str(%') find file "&wordfileref".; %end; %end; %else %do; %put --> Note: No word document is provided, system is opening a new one for you.; Filename wordsys dde 'winword|system' lrecl=1048576; %let fid=%sysfunc(fopen(wordsys, s)); data _null_; %if (&fid le 0) %then %do; rc=system("start winword"); x 'Exit'; fid=fopen("wordsys", "s"); do until(fid); fid=fopen("wordsys", "s"); end; rc=fclose(fid); %end; %else %do; %let rc=%sysfunc(fclose(&fid)); file wordsys; put '[FileNewDefault]'; %end; run; %end; %mend wordopen;